package com.wh.blog.mapper;

import com.wh.blog.model.BlogInfo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface BlogMapper {
    @Select("select * from blog where delete_flag =0")
    public List<BlogInfo> getBlogList();

    /**
     * 根据博客ID, 返回博客信息
     *
     * @return
     */
    @Select("select * from blog where id =#{id} and delete_flag =0")
    BlogInfo selectById(Integer id);

    Integer updateBlog(BlogInfo blogInfo);

    @Insert("insert into blog (title, content, user_id) values (#{title}, #{content}, #{userId})")
    Integer addBlog(BlogInfo blogInfo);
}
